<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <base href="${request.contextPath}/"/>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0,minimum-scale=1.0">
    <title>创建订单</title>
    <link href="Content/wechat/css/reset.css" rel="stylesheet" type="text/css">
    <!--签到-->
    <link href="Content/wechat/css/dangJian_gongZhuGongJian_CJHD.css" rel="stylesheet" type="text/css">
    <script src="Content/wechat/js/jquery.min.js"></script>
    <script src="Content/wechat/js/jquery.validate.js"></script>
    <!--字体缩放-->
    <script src="Content/wechat/js/ziti.js"></script>
    <!--end 字体缩放-->
    <!--上传图片js-->
    <script src="js/svg.js"></script>
    <!--end 上传图片js-->
</head>
<body>
<form id="form1">
    <input type="hidden" name="goodsid" id="goodsid" value="${goodsid!}">
    <div class="xinyuan">
        <div class="xinyuan_box">

            <dl class="clearfix">
                <dt>收货地址</dt>
                <dd><select id="shaddress" name="shaddress">
                    <option value="">---请选择---</option>
                </select>
                </dd>
            </dl>

            <h4>备注信息：</h4>
            <textarea class="textarea" id="content" name="content" placeholder="请简要说明"></textarea>
        </div>
        <div class="button_shangChuan" id="btnAdd">提交</div>
    </div>

</form>
</body>
<script>
var shaddress=${shaddress!};

    $.each(shaddress.rows, function (index, items) {
        $("#shaddress").append("<option value='" + items.id + "'>" + items.name + " "+items.phone+" "+items.info+"</option>");
    });

var btnAdd = true;


$().ready(function () {
    $(".button_shangChuan").click(function () {
            if (!btnAdd) {
                alert("提交中...");
                return;
            }
            if ($("#form1").valid()) {
                btnAdd = false;
                $("#btnAdd").html("提交中...")
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "/wechat/forum/mall/insert",//url
                    data: $('#form1').serialize(),
                    success: function (result) {
                        console.log(result);//打印服务端返回的数据(调试用)
                        if (result.code == 200) {
                            alert(result.info);
                            window.location.href="/wechat/forum";
                        } else {
                            alert("请稍后再试");
                            btnAdd = true;
                            $("#btnAdd").html("提交");
                        }
                    },
                    error: function () {
                        alert("异常！");
                        btnAdd = true;
                        $("#btnAdd").html("提交");
                    }
                });
            }
        }
    );
    $("#form1").validate({
        rules: {
            shaddress: {
                required: true,

            }

        },
        messages: {
            shaddress: {
            }
        }

    })
});
</script>
</html>